﻿/*----------------------------------------------------------------
  //Copyright (C) 2012 赵国伟
  //文件功能描述：库房管理Ajax请求服务端处理程序。
  //创建人：赵国伟
  //生成时间：2012/04/01 01:15:00
//----------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Shopping.Common;
using Shopping.Model;
using Shopping.BLL;

public partial class Manage_AS_StoresCommon : BaseManagePage
{
    private readonly StoresManage bllStore = new StoresManage();
    private ReturnValue ret = new ReturnValue(ResultType.Fail); 

    protected void Page_Load(object sender, EventArgs e)
    {
        string action = Request.QueryString["Action"] as string;
        switch (action)
        {
            case "SaveStore":   //保存库房信息； by 赵国伟 2012/04/01
                SaveStore();
                break;
            case "GetStoreInfo":  //获取一条库房信息；by 赵国伟 2012/04/01
                GetStoreInfo();
                break;
            case "DeleteStore":  //删除一条库房信息； by 赵国伟 2012/04/01
                DeleteStore();
                break;
            case "SaveSupplier":   //保存供应商信息； by 赵国伟 2012/04/04
                SaveSupplier();
                break;
            case "GetSupplierInfo":  //获取一条供应商信息；by 赵国伟 2012/04/04
                GetSupplierInfo();
                break;
            case "DeleteSupplier":  //删除一条供应商信息； by 赵国伟 2012/04/04
                DeleteSupplier();
                break;
            case "QueryStockRecords": //查询指定商品的进出货记录；by 赵国伟 2012/06/10
                QueryStockRecords();
                break;
            case "SaveStockInInfo":  //保存入库单信息；by 赵国伟 2012/06/10
                SaveStockInInfo();
                break;
            case "SaveStockOutInfo"://保存出库单信息；by 赵国伟 2012/06/10
                SaveStockOutInfo();
                break;
            case "DeleteStockIn":  //删除一条指定的入库单信息； by 赵国伟 2012/06/10
                DeleteStockIn();
                break;
            case "DeleteStockOut": //删除一条指定的出库单信息； by 赵国伟 2012/06/10
                DeleteStockOut();
                break;
            case "GetStockOutInfo":  //查询一条出库单信息； by 赵国伟 2012/06/10
                GetStockOutInfo();
                break;
            case "GetStockInInfo":   //查询一条入库单信息； by 赵国伟 2012/06/10;
                GetStockInInfo();
                break;

        }
        Response.End();
    }

    #region "保存库房信息； by 赵国伟 2012/04/01"
    /// <summary>
    /// 保存库房信息
    /// </summary>
    private void SaveStore()
    {
        ret = BLLHelper.Save<StoresManage, Stores>("SaveStore");
        Response.Write(ret.ToJsonString());
    }
    #endregion

    #region "获取一条库房信息； by 赵国伟 2012/04/01"
    /// <summary>
    /// 获取一条库房信息
    /// </summary>
    private void GetStoreInfo()
    {
        int StoreID = Utility.G<int>("StoreID");
        Stores data = bllStore.GetStoreInfo(StoreID);
        if (data != null)
            Response.Write(data.ToJsonString());
    }
    #endregion

    #region "删除一条库房信息； by 赵国伟 2012/04/01"
    /// <summary>
    /// 删除一条库房信息
    /// </summary>
    private void DeleteStore()
    {
        int StoreID = Utility.G<int>("StoreID");
        Response.Write(bllStore.DeleteStore(StoreID).ToJsonString());
    }
    #endregion


    #region "保存供应商信息；  by 赵国伟 2012/04/04"
    /// <summary>
    /// 保存供应商信息
    /// </summary>
    private void SaveSupplier()
    {
        ret = BLLHelper.Save<StoresManage, Suppliers>("SaveSupplier");
        Response.Write(ret.ToJsonString());
    }
    #endregion

    #region "获取一条供应商信息； by 赵国伟 2012/04/04"
    /// <summary>
    /// 获取一条供应商信息
    /// </summary>
    private void GetSupplierInfo()
    {
        int SupplierID = Utility.G<int>("SupplierID");
        Suppliers data = bllStore.GetSupplierInfo(SupplierID);
        if (data != null)
            Response.Write(data.ToJsonString());
    }
    #endregion

    #region "删除一条供应商信息； by 赵国伟 2012/04/04"
    /// <summary>
    /// 删除一条供应商信息
    /// </summary>
    private void DeleteSupplier()
    {
        int SupplierID = Utility.G<int>("SupplierID");
        Response.Write(bllStore.DeleteSupplier(SupplierID).ToJsonString());
    }
    #endregion




    #region "查询指定商品的进出货记录； by 赵国伟 2012/06/09"
    /// <summary>
    /// 查询指定商品的进出货记录；
    /// </summary>
    private void QueryStockRecords()
    {
        int GoodsID = Utility.G<int>("GoodsID");
        int StoreID = Utility.G<int>("StoreID");

        List<GoodsStockRcordInfo> list = bllStore.QueryStockRecords(GoodsID, StoreID);
        if (list != null)
            Response.Write(JSONHelper.ObjectToJson<List<GoodsStockRcordInfo>>(list));
    }
    #endregion

    #region "保存入库单信息 by 赵国伟 2012/06/10"
    /// <summary>
    /// 保存入库单信息
    /// </summary>
    private void SaveStockInInfo()
    {
        ret = BLLHelper.Save<StoresManage, StockInsInfo>("SaveStockInInfo");
        Response.Write(ret.ToJsonString());
    }
    #endregion

    #region "保存出库单信息 by 赵国伟 2012/06/10"
    /// <summary>
    /// 保存出库单信息
    /// </summary>
    private void SaveStockOutInfo()
    {
        ret = BLLHelper.Save<StoresManage, StockOutsInfo>("SaveStockOutInfo");
        Response.Write(ret.ToJsonString());
    }
    #endregion

    #region "删除一条指定的入库单信息； by 赵国伟 2012/06/10"
    /// <summary>
    /// 删除一条指定的入库单信息；
    /// </summary>
    private void DeleteStockIn()
    {
        int stockInId = Utility.G<int>("StockInID");
        Response.Write(bllStore.DeleteStockIn(stockInId).ToJsonString());
    }
    #endregion

    #region "删除一条指定的出库单信息； by 赵国伟 2012/06/10"
    /// <summary>
    /// 删除一条指定的出库单信息；
    /// </summary>
    private void DeleteStockOut()
    {
        int stockOutId = Utility.G<int>("StockOutID");
        Response.Write(bllStore.DeleteStockOut(stockOutId).ToJsonString());
    }
    #endregion

    #region "查询一条出库单信息； by 赵国伟 2012/06/10"
    /// <summary>
    /// 查询一条出库单信息；
    /// </summary>
    private void GetStockOutInfo()
    {
        int stockOutId = Utility.G<int>("StockOutID");
        StockOutsInfo d = bllStore.GetStockOutInfo(stockOutId);
        if (d != null)
            Response.Write(JSONHelper.ObjectToJson<StockOutsInfo>(d));

    }
    #endregion

    #region "查询一条入库单信息； by 赵国伟 2012/06/10"
    /// <summary>
    /// 查询一条入库单信息；
    /// </summary>
    private void GetStockInInfo()
    {
        int stockInId = Utility.G<int>("StockInID");
        StockInsInfo d = bllStore.GetStockInInfo(stockInId);
        if (d != null)
            Response.Write(JSONHelper.ObjectToJson<StockInsInfo>(d));

    }
    #endregion





}